<?php
class models_thanhtoan extends connect{
	function getuser($id)
	{
		$sql="SELECT MaUser,TenUser ,DienThoai,Email,DiaChi
				FROM user
				WHERE TenUser= '$id'";
		$this->query_db($sql);
		return $this->fetchOne();
	}
	function listkh(){
		
		$sql = "SELECT MaKH, TenKH, DiaChi, SDT
				FROM khachhang ";
		$this->query_db($sql);
		return $this->fetchAll();
	}
	function addkhachhang($TenKH,$DiaChi,$SDT){
		$sql = "INSERT INTO khachhang VALUES('','$TenKH','$DiaChi','$SDT')";
		$this->query_db($sql);
	}
	function getkhachhang($id)
	{
		$sql = "SELECT *
				FROM khachhang 
				WHERE TenKH = '$id'";
		$this->query_db($sql);
		return $this->fetchOne();	
	}
	function addHoaDon($MaKH,$NgayLap,$NguoiLap){
			$sql = "INSERT INTO hoadon VALUES ('','$MaKH','$NgayLap','$NguoiLap','')";
			$this->query_db($sql);
		}
	function gethoadon($id){
			$sql  = "SELECT MaHD 
					 FROM hoadon
					 WHERE NgayLap = '$id'";
			$this->query_db($sql);
			return $this->fetchOne();
		}
	function _addCTHoaHon($MaMH, $MaHD, $SoLuongBan, $DonGiaBan){
			$sql = "INSERT INTO chitiethoadon VALUES('','$MaMH','$MaHD','$SoLuongBan','$DonGiaBan','')";
			$this->query_db($sql);
		}
		function getmathang($ma)
		{
			$sql="SELECT MaMH,TenMH
					FROM mathang
					WHERE TenMH='$ma'";
			$this->query_db($sql);	
			return $this->fetchOne();
			
		}
}